﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Particles
{

    public class SmokeEffect : BaseParticleSystem
    {
        public SmokeEffect(Particle_Editor.Game1 theGame, int NumberOfEffects)
            : base(theGame, NumberOfEffects)
        {
        }
        protected override void InitializeConstants()
        {

            if (Particle_Editor.Game1.UsingExternalTexture == true)
            {
                try
                {
                    ParticleTexture = Texture2D.FromFile(game.GraphicsDevice, Particle_Editor.Game1.ExternalTextureFileName);
                }
                catch
                {
                    MessageBox.Show("The texture associated with this particle effect failed to load. Please verify that it exists. A default texture will be used instead.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Particle_Editor.Game1.UsingExternalTexture = false;
                    ParticleTextureFilename = "NoTexture";
                }
            }
            else
            {
                ParticleTextureFilename = Particle_Editor.Game1.CurrentParticleTexture;
            }

            MinimumInitialSpeed = Particle_Editor.Game1.MinParticleSpeed;//20;
            MaximumInitialSpeed = Particle_Editor.Game1.MaxParticleSpeed;//100;

            MinimumAcceleration = Particle_Editor.Game1.MinParticleAcceleration;//0;
            MaximumAcceleration = Particle_Editor.Game1.MaxParticleAcceleration;//0;

            MinimumLifetime = Particle_Editor.Game1.MinParticleLifetime;//5.0f;
            MaximumLifetime = Particle_Editor.Game1.MaxParticleLifetime;//7.0f;

            MinimumScale = Particle_Editor.Game1.MinParticleScale;//0.5f;
            MaximumScale = Particle_Editor.Game1.MaxParticleScale;//1.0f;

            MinimumNumberOfParticles = Particle_Editor.Game1.MinNumberOfParticles;//7;
            MaximumNumberOfParticles = Particle_Editor.Game1.MaxNumberOfParticles;//15;

            MinimumRotationSpeed = -MathHelper.ToRadians(Particle_Editor.Game1.MinParticleRotationSpeed);//-MathHelper.PiOver4 / 2.0f;
            MaximumRotationSpeed = MathHelper.ToRadians(Particle_Editor.Game1.MaxParticleRotationSpeed);//MathHelper.PiOver4 / 2.0f;

            spriteBlendMode = SpriteBlendMode.AlphaBlend;

            DrawOrder = AlphaBlendDrawOrder;

        }

        protected override Vector2 PickRandomDirection()
        {
            float min = MathHelper.ToRadians(Particle_Editor.Game1.MinimumParticleAngle);//MathHelper.ToRadians(0);//
            float max = MathHelper.ToRadians(Particle_Editor.Game1.MaximumParticleAngle);//MathHelper.ToRadians(90);//
            float theAngle = Particle_Editor.Game1.GetRandomNumber(min, max);
           
            Vector2 direction = Vector2.Zero;
            
            direction.X = -(float)Math.Sin(theAngle);
            direction.Y = (float)Math.Cos(theAngle);
            return direction;
        }

        protected override void InitializeParticle(Particle theParticle, Vector2 theLocation)
        {
            
            base.InitializeParticle(theParticle, theLocation);
       
        }

    }
}
